<%@ page language="Java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>


<form:form action="addTour.html" method="post" commandName="addTourForm">
	<fieldset style="width: 50%; padding: 25px 30px 25px 30px;">

		<legend class="formElement">Dane nowej wycieczki</legend>

		<div class="formElement">
			<form:label path="dateFrom" cssClass="formElement">Data rozpoczęcia</form:label>
			<form:input path="dateFrom" cssClass="formElement" />
		</div>

		<div class="formElement">
			<form:label path="dateTo" cssClass="formElement">Data zakończenia</form:label>
			<form:input path="dateTo" cssClass="formElement" />
		</div>

		<div class="formElement">
			<form:label path="hotelId" cssClass="formElement">Hotel</form:label>
			<form:select id="hotelList" path="hotelId"  onchange="getPlacesInHotel()" cssClass="formElement">
			<form:option value="-1" label="--Wybierz hotel"/>
			<form:options items="${hotels}" itemLabel="name" itemValue="id"/>
			</form:select>
		</div>

		<div class="formElement" style="display:inline">
			<form:label path="placeQuantity" cssClass="formElement">Liczba miejsc</form:label>
			<form:input path="placeQuantity"  cssClass="formElement"/>
		</div>
		
		<span id="maxPlaceQuantitySpan" style="display:inline"></span>

		<div class="formElement">
			<form:label path="basePrice" cssClass="formElement">Cena za osobę</form:label>
			<form:input path="basePrice" cssClass="formElement"/>
		</div>
		
		<div class="formElement">
			<form:label path="description" cssClass="formElement">Opis</form:label>
			<form:input size="100" path="description" cssClass="formElement"/>
		</div>

		<div class="formElement">
			<input type="submit" value="Dodaj wycieczkę" />
		</div>

	</fieldset>
</form:form>


<script type="text/javascript">
 

function test() {
	jq(function(){ 
		
		//jq("#description" + param).html('<div id=' + divId + '> cos tam </div>');
		//jq("#description").html('<div id=' + divId + '> cos tam </div>');
		divId='teeeeeeeeeeeeeeeeest';
		in1=jq("#hotelList").val();
		alert(in1);
		alert(divId);
	});
}


function getPlacesInHotel() {
	jq(function() {
		var hotelId=jq("#hotelList").val();
		if(hotelId!=-1){
		jq.post("/TourWebSpring/placesInHotel.html",
			{hotelId: hotelId},
		 function(data) {
			//var divId = '\"description' + tourId + '\"'; 
			//jq("#description" + tourId).replaceWith('<div id=' + divId + '>' + data + '</div>');
			jq("#maxPlaceQuantitySpan").html('Maksymalnie miejsc: '+ data);
		});
		}
	});
}
</script>
